package com.whosly.study.webflux.controller;

import com.example.grpc.GreetingService;
import com.example.grpc.GreetingServiceOuterClass;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author fengyang(yueny09 @ 163.com)
 * @date 2022年05月07日 下午7:52
 */
@RestController
public class GetController {
    @Autowired
    private GreetingService greetingService;

    /**
     * http://localhost:8061/get
     *
     */
    @RequestMapping("/get")
    public String greetingService() {
        GreetingServiceOuterClass.HelloRequest request =
                GreetingServiceOuterClass.HelloRequest.newBuilder()
                        .setName("request")
                        .build();

        GreetingServiceOuterClass.HelloResponse resp = greetingService.greeting(request);

        return resp.getGreeting();
    }

}
